Page({
  data: {
    mushroom: null,
    toxicityMap: {
      1: '无毒',
      2: '微毒',
      3: '剧毒'
    }
  },

  onLoad: function(options) {
    const mushroomData = JSON.parse(decodeURIComponent(options.mushroomData));
    
    // 使用正则表达式替换空格为 %20
    mushroomData.icon_url = mushroomData.icon_url.replace(/ /g, '%20');
    
    console.log('处理后的图片URL:', mushroomData.icon_url);
    
    this.setData({
      mushroom: mushroomData
    });
  },

  onImageError(e) {
    console.error('图片加载失败:', e);
    wx.showToast({
      title: '图片加载失败',
      icon: 'none'
    });
  },

  // 添加图片点击预览功能
  onImageClick() {
    wx.previewImage({
      urls: [this.data.mushroom.icon_url],
      current: this.data.mushroom.icon_url
    });
  }
}); 